/******************************************************************************/
package jamie.org.sil.www.UsxVernacularCreator;

import javax.swing.table.*;


/******************************************************************************/
/** Table model.
 * <p>
 *
 * This is driven largely by the needs of AbstractTableModel, and I don't
 * profess to understand it properly.
 *
 * @author Jamie
 */

public class GuiInputTableModel extends AbstractTableModel
{
  public GuiInputTableModel (int guiTabNo) { m_GuiTabNo = guiTabNo; }
  
  public int getColumnCount () { return 2; } // Prompt and value.

  public int getRowCount () { return XmlDetailsVernacularAdditional.instance().getTagCount(m_GuiTabNo); }

  @Override public String getColumnName (int col) { return ""; }

  public Object getValueAt (int row, int col)
  {
    if (0 == col)
      return XmlDetailsVernacularAdditional.instance().getTag(m_GuiTabNo, row).getPrompt();
    else
      return XmlDetailsVernacularAdditional.instance().getTag(m_GuiTabNo, row).getValue();
  }

  @Override public Class getColumnClass (int c) { return getValueAt(0, c).getClass(); }

  @Override public boolean isCellEditable (int row, int col) { return XmlDetailsVernacularAdditional.instance().getTag(m_GuiTabNo, row).isEditable(col); }

  @Override public void setValueAt (Object value, int row, int col)
  {
    XmlDetailsVernacularAdditional.instance().getTag(m_GuiTabNo, row).setValue(value);
    fireTableCellUpdated(row, col);
  }

  private int m_GuiTabNo;
}
